package com.snopy.concurrency.adder;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

/**
 * @author snopy
 * @version 1.0.0
 * @classname DemoAdder
 * @description 标记清除
 * @email 77912204@qq.com
 * @date 2022/06/30 20:46
 */
@Slf4j
public class DemoAdder {
    public static void main(String[] args) {

        LongAdder adder = new LongAdder();
        AtomicInteger num = new AtomicInteger(1);
        new Thread(()->{
            num.incrementAndGet();
            adder.increment();
        }).start();
        new Thread(()->{
            num.incrementAndGet();
            adder.increment();
        }).start();
        new Thread(()->{
            num.incrementAndGet();
            adder.increment();
        }).start();

        log.debug("sum:{},num:{}",adder.sum(),num);
    }
}
